#include "src/intersect/line_arc_intersect.cpp"

static void GenerateTest() {

    int num_tests = 1000;
    double min = -100.0, max = 100.0;

    for (int i = 0; i < num_tests; i++) {

        Point line_start = { RandomDouble(min, max), RandomDouble(min, max) };
        Point line_end = { RandomDouble(min, max), RandomDouble(min, max) };
        Point center = { RandomDouble(min, max), RandomDouble(min, max) };
        double radius = RandomDouble(1, 50);
        double startangle = (RandomDouble(0, 360)) * M_PI / 180.0;
        double endangle = startangle + (RandomDouble(0, 180)) * M_PI / 180.0;

        Arc circle_arc(center, radius);


        std::vector<Point> intersections;
        std::cout << "Test " << i + 1 << ": \n";

        std::cout << std::fixed << std::setprecision(2);
        std::cout << "Line : (" << line_start.x << ", " << line_start.y << ") to (" << line_end.x << ", " << line_end.y << ")\n";
        std::cout << "Arc cneter: (" << center.x << ", " << center.y << "),radius: " << radius << std::endl;
        std::cout << "Arc start angle: " << startangle << ",endangle: " << endangle << std::endl;

        if (circle_arc.FindInterSections(line_start, line_end, intersections)) {

            std::cout << "The circleArc and the line segment intersect at:" << std::endl;

            for (const Point& p : intersections) {

                std::cout << std::fixed << std::setprecision(2);
                std::cout << "(" << p.x << "," << p.y << ") ";
            }
            std::cout << std::endl;
            std::cout << std::endl;
        }
        else {

            std::cout << "The circleArc and the line segment do not intersect.\n" << std::endl;

        }
    }

}

int main()
{
    GenerateTest();

    return 0;

}
